import axios from '@/utils/request'
import {ref} from 'vue'

let authorityId = ref('')

//请求权限组信息
export async function getAuthoritysInfo(){
    let getAuthoritysInfo = await axios.get('/index/authoritys/getAuthoritysInfo')
    return getAuthoritysInfo
}


//请求已存在的权限
export async function hasDirsInfo(id){
    // console.log(id);   
    authorityId.value = id
    let hasDirsInfo = await axios.get(`/index/authoritys/hasDirsInfo?id=${id}`)
    return hasDirsInfo
}

//更新、新增、删除权限组
export async function editAuthorityInfo(type,form){
    let data = {
        submitType:type,
        submitForm:form
    }   
    let newAuthoritys = await axios.post('/index/authoritys/editAuthoritysInfo',data)
    return newAuthoritys
}

//获取目录及中间表信息
export async function getDirsAndMidInfo(id){
    let getDirsAndMidInfo = await axios.post('/index/authoritys/getDirsAndMidInfo',{id})
    return getDirsAndMidInfo
}

//变更权限明细
export async function changeAuthority(type,form){
    let data = {
        // authorityId:authorityId.value,
        submitType:type,
        submitForm:form
    }   
    let newAuthoritys = await axios.post('/index/authoritys/changeAuthority',data)
    return newAuthoritys
}

